package com.hc24.util;
import java.lang.reflect.InvocationTargetException;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.ConvertUtils;

/**
 * 为支持Date类型转换做的改进
 * @author hc24
 */
public class BeanUtilsEx extends BeanUtils {
    static {
        ConvertUtils.register(new StringToDateConvert(), java.util.Date.class);
        ConvertUtils.register(new StringToDateConvert(), java.sql.Date.class);
        ConvertUtils.register(new DateToStringConvert(), String.class);
    }

    public static void copyProperties(Object dest, Object orig) {
        try {
            BeanUtils.copyProperties(dest, orig);
        } catch (IllegalAccessException ex) {
            ex.printStackTrace();
        } catch (InvocationTargetException ex) {
            ex.printStackTrace();
        }
    }
}
